<?php

/**
 * This is the model class for table "receivables".
 *
 * The followings are the available columns in table 'receivables':
 * @property integer $id ID
 * @property string $receiver 收款人
 * @property string $payer 付款人
 * @property string $receiveable 应收金额
 * @property string $received 已收金额
 * @property string $status Status
 * @property string $object_type Object Type
 * @property string $create_time 创建时间
 * @property integer $relate_id Relate
 */
class Receivables extends ActiveRecord
{
	public $sn;
	/**
	 * 应收单
	 * Enter description here ...
	 * @var unknown_type
	 */
	const TYPE_RA = 'Receivable';
	/**
	 * 收款单
	 * Enter description here ...
	 * @var unknown_type
	 */
	const TYPE_R = 'Receiver';
//	const TYPE_PAYVABLE

	public $type;
	/**
	 * Returns the static model of the specified AR class.
	 * @return Receivables the static model class
	 */
	public static function model($className=__CLASS__) {
		return parent::model($className);
	}
	
	public function getMdcClass() {
		return 'application.models.metadata.ReceivablesMetadata';
	}
	
	public static function createOrder($objectType, $data=array()) {
		$model = NULL;
		switch ($objectType) {
			case self::TYPE_RA:
				$model = new Receivable();
				break;
			default:
				break;
		}
		if($model)
			$model->attributes = $data;
		return $model;
	}
}